using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace EditWebSite.Controls
{
    public partial class IntelliList : ListBox
    {
        public IntelliList()
        {
            InitializeComponent();
            this.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ForeColor = Color.Black;
            this.BackColor = Color.WhiteSmoke;
            this.DrawMode = DrawMode.OwnerDrawFixed;
        }

        

        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            Rectangle bounds = e.Bounds;
            string item;
            try
            {
                item = (string)Items[e.Index];

                e.Graphics.DrawString(item, e.Font, new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
            }
            catch
            {
                if (e.Index != -1)
                {
                    e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
                        new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
                }
                else
                {
                    e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                        bounds.Left, bounds.Top);
                }
            }
            base.OnDrawItem(e);
        }
    }
}
